<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<script>
$(function(){
	$("select[name='voucherTemplate.state']").val('${voucherTemplate.state}');
});
function brandChoose(){
	$("#voucherTemplateBrandAId").attr("href","${rootUrl}/goods/brand/0/multipleDialog?multipleDialogMyIds="+$("input[name='brand.id']").val()+"&multipleDialogMyNames="+$("input[name='brand.name']").val());
}

function goodsClassChoose(){
	$("#voucherTemplateGoodsClassAId").attr("href","${rootUrl}/goods/goods-class/0/multipleDialog?multipleDialogMyIds="+$("input[name='goodsClass.id']").val()+"&multipleDialogMyNames="+$("input[name='goodsClass.name']").val());
}

function typeClassChoose(){
	$("#voucherTemplateTypeClassAId").attr("href","${rootUrl}/goods/type-class/0/multipleDialog?multipleDialogMyIds="+$("input[name='typeClass.id']").val()+"&multipleDialogMyNames="+$("input[name='typeClass.name']").val());
}

function beforeSubmit(obj){
	$("input[name='brand.id']").attr("name","voucherTemplate.goodsBrand");
	$("input[name='brand.name']").attr("name","voucherTemplate.goodsBrandName");
	$("input[name='goodsClass.id']").attr("name","voucherTemplate.goodsClass");
	$("input[name='goodsClass.name']").attr("name","voucherTemplate.goodsClassName");
	$("input[name='typeClass.id']").attr("name","voucherTemplate.goodsType");
	$("input[name='typeClass.name']").attr("name","voucherTemplate.goodsTypeName");
	
	return validateCallback(obj, editDialogAjaxDone);
}

</script>
<div class="pageContent">
	<form method="post" action="${rootUrl}/member/voucher-template/${voucherTemplate.id}" class="pageForm required-validate" onsubmit="return beforeSubmit(this);">
		<c:if test="${voucherTemplate.id != 0}"><input type="hidden" name="_method" value="put"></c:if>
		<input type="hidden" name="voucherTemplate.id" value="${voucherTemplate.id }">
		<div class="pageFormContent" layoutH="58">
	 		<p>
				<label>编码</label>
				<input  type="text" size="30" name="voucherTemplate.code" value="${voucherTemplate.code }" class="required"/>
			</p>
			
			<p>
				<label>名字</label>
				<input  type="text" size="30" name="voucherTemplate.name" value="${voucherTemplate.name }" class="required"/>
			</p>
			
			<p>
				<label>描述</label>
				<input  type="text" size="30" name="voucherTemplate.description" value="${voucherTemplate.description }" />
			</p>
			
			<p style="width:900px">
				<label>品牌：</label>
				<input name="brand.name" type="text" value="${voucherTemplate.goodsBrandName }" style="width:600px" readonly="readonly"/>
				<input type="hidden" name="brand.id" value="${voucherTemplate.goodsBrand }">
				<a id="voucherTemplateBrandAId" class="btnLook" onclick="brandChoose()" width="1000" height="600" lookupGroup="brand">品牌</a>
				
			<p style="width:900px">
				<label>商品类型：</label>
				<input name="goodsClass.name" type="text" value="${voucherTemplate.goodsClassName }" style="width:600px" readonly="readonly"/>
				<input type="hidden" name="goodsClass.id" value="${voucherTemplate.goodsClass }">
				<a id="voucherTemplateGoodsClassAId" class="btnLook" onclick="goodsClassChoose()" width="1000" height="600" lookupGroup="goodsClass">类别</a>
			</p>
			
			<p style="width:900px">
				<label>商品类别：</label>
				<input name="typeClass.name" type="text" value="${voucherTemplate.goodsTypeName }" style="width:600px" readonly="readonly"/>
				<input type="hidden" name="typeClass.id" value="${voucherTemplate.goodsType }">
				<a id="voucherTemplateTypeClassAId" class="btnLook" onclick="typeClassChoose()" width="1000" height="600" lookupGroup="typeClass">类别</a>
			</p>
			
			<p>
				<label>开始时间</label>
				<input name="voucherTemplate.startDate" name="voucherTemplate.startDate" class="date" type="text" size="30" value="<fmt:formatDate value='${voucherTemplate.startDate }' pattern='yyyy-MM-dd'/>"/><br>
			</p>
			
			<p>
				<label>使用期限(天)</label>
				<input  type="text" size="30" name="voucherTemplate.timeLimit" value="${voucherTemplate.timeLimit }" class="required number"/>
			</p>
			
			<p>
				<label>订单限额</label>
				<input  type="text" size="30" name="theLimitMoney" value="<fmt:formatNumber value="${voucherTemplate.limitMoney/100}" pattern="0.00"/>" class="required number"/>
			</p>
			<p>
				<label>面额(元)</label>
				<input  type="text" size="30" name="thePrice" value="<fmt:formatNumber value="${voucherTemplate.price/100}" pattern="0.00"/>" class="number"/>
			</p>
			<p>
				<label>可发放总数</label>
				<input  type="text" size="30" name="voucherTemplate.total" value="${voucherTemplate.total }" class="required number"/>
			</p>
			<p>
				<label>已发放数量</label>
				<input  type="text" size="30" name="voucherTemplate.giveout" value="${voucherTemplate.giveout }" class="required number"/>
			</p>
			<p>
				<label>积分兑换</label>
				<input  type="text" size="30" name="voucherTemplate.points" value="${voucherTemplate.points }" class="required number"/>
			</p>
			<p>
				<label>状态</label>
				<select name="voucherTemplate.state">
					<option value="1">有效</option>
					<option value="0">无效</option>
				</select>
			</p>
		</div>
			
	
			<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button id="theSubmit" type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
			</div>
	</form>
</div>
